<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>发送留言</title>
		<link rel="stylesheet" type="text/css" href="css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="css/layui.css"/>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/layer/layer.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			.sub-btn{
				display: block;
				color: white;
			}
			body{
				padding: 0.3125rem;
				background-color: #F3F4F6;
			}
			.tips{
				margin: 0.625rem 0rem;
				color: #C9C9C9;
			}
			.star{
				color: red;
				margin-left: 0.325rem;
			}
			.layui-form-item>div{
				margin-bottom: 0.25rem;
				color: #4E5465;
			}
		</style>
	</head>
	<body>
		<div class="layui-form">
			<div class="tips">请填写以下信息，我们会尽快和您联系。</div>
			<div class="layui-form-item">
				<div>您的姓名 <span class="star">*</span></div>
					<input type="text" class="layui-input" required  lay-verify="required" id="name" placeholder="您的姓名">
			</div>
			<div class="layui-form-item">
				<div>电话号码<span class="star">*</span></div>
				<input type="number" class="layui-input" id="tel" lay-verify="phone" placeholder="电话号码">
			</div>
			<div class="layui-form-item">
				<div>电子邮箱</div>
				<input type="text" class="layui-input" id="email" placeholder="电子邮箱">
			</div>
			<div class="layui-form-item">
				<div>留言内容</div>
				 <textarea name="desc" placeholder="请输入内容" id="content" class="layui-textarea"></textarea>
			</div>
			<button class="layui-btn layui-btn-fluid" style="background-color: #11b6f5;">提交</button>
		</div>
	</body>
	<script src="js/config.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
	
		$(".layui-btn").click(function(){
			let name = $("#name").val(),tel = $("#tel").val(),email = $("#email").val(),content= $("#content").val();
			if(name.length<1){
				layer.msg("请填写您的姓名");
				return;
			}
			if(tel.length<1){
				layer.msg("请填写您的手机号码");
				return;
			}
			let reg = /^1(3\d|4[5-8]|5[0-35-9]|6[567]|7[01345-8]|8\d|9[025-9])\d{8}$/;
			if(!reg.test(tel)){
				layer.msg("请填写正确的手机号");
				return;
			}
			let reg3 = /</g;
			let reg2 = />/g;
			name=name.replace(reg3,'&lt;').replace(reg2,'&gt;')
			content=content.replace(reg3,'&lt;').replace(reg2,'&gt;')
			email=email.replace(reg3,'&lt;').replace(reg2,'&gt;')
			var d = {"zxphone":tel,"zxname":name,"zxemail":email,"zxmsg":content};
			$.ajax({
				url:"/h5/zixunadd",
				type:"post",
				data:JSON.stringify(d),
				// data:{"zxname":name	},
				contentType: 'application/json',
				success: (res) => {
						console.log(res);
						if(res.code==200){
							layer.msg("提交成功，我们会尽快安排人联系您！")
							window.history.back();
						}else{
							console.log("请求失败");
						}
				}
			})
	
	})
		
	</script>
</html>
